﻿
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>系统导航菜单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/X-admin/lib/layui/layui.all.js"></script>
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
</head>
<body>
    <div id="bDiv">
    </div>

    <div class="layui-card" style="margin-top:10px">
        <div class="layui-card-body" style="padding-top:4%">
            <form id="dForm" class="layui-form layui-col-space5" lay-filter="form-filter">
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                     编 码
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="cCode" name="cCode"   class="layui-input">
                    </div>

                    <label for="L_email" class="layui-form-label">
                        名 称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="cName" name="cName"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        节点编码
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="parentCode" name="parentCode" class="layui-input" readonly />
                    </div>

                </div>
                <div class="layui-form-item layui-form-text">
                    <label for="L_email" class="layui-form-label">
                        备注说明
                    </label>
                    <div class="layui-input-block">
                        <input type="text" id="cMemo" name="cMemo"  class="layui-input">
                    </div>

                </div>
                <input type="hidden" name="id" id="id">
                <input type="hidden" name="cType" id="cType">

            </form>
        </div>
    </div>

</body>
</html>

<script type="text/javascript">
    var gvalue = "", fvalue = "";
    var dataId = "";
    $(function () {
        gvalue = getUrlVariable("gvalue");
        fvalue = getUrlVariable("fvalue");
        dataId = getUrlVariable("dataId");
        $("input[ name='cType']").val(gvalue);
        BannerData("comUpdate", "bDiv");
        if (dataId != "0" && dataId != "") {
            loadData();
        } else { 
            if (fvalue == "") {
                $("input[ name='parentCode']").val(gvalue);
            } else {
                $("input[ name='parentCode']").val(fvalue);
            }
        }


    });

    // 保存数据
    function saveData() {
        $.ajax({
            url: "../Basic/UpdateCommonData",
            data: { datas: JSON.stringify(FormToJson("dForm")) },
            dataType: "json",
            type: "POST",
            success: function (data) {
                if (data.result) {
                    layer.msg("保存成功");
                } else {
                    layer.msg(data.message);
                }
            }
        });
    }

    //加载数据信息
    function loadData() {
        $.ajax({
            url: "../Basic/getCommonDataById",
            type: "post",
            data: { dataId: dataId },
            success: function (data) {
                if (data.result) {
                
                    layui.use('form', function () {
                        var form = layui.form;
                        form.val('form-filter', data.data[0]);
                        form.render();
                    });
                }
            }
        });
    }
    /**
     * 获取全部有效菜单
     * **/
    function MenuInfo() {
        $.ajax({
            url: "../System/getEnableMenuInfo",
            dataType: "json",
            type: "POST",
            success: function (data) {
                if (data.result) {
                    var datas = data.data;
                    for (var i = 0; i < datas.length; i++) {
                        $("#parentMenu").append("<option value=\"" + datas[i]["menuCode"] + "\" >" + datas[i]["menuName"] + "(" + datas[i]["menuCode"] + ")" + "</option>");
                    }
                    layui.use('form', function () {
                        var form = layui.form;
                        form.render();
                    });
                }
            }
        });
    }
</script>

